using System.ComponentModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Be.Timvw.Framework.ComponentModel
{
    [TestClass]
    public class WhenRemovingSortOnSortableBindingLists
    {
        [TestMethod]
        public void ShouldReturnFalseForIsSorted()
        {
            IBindingList bindingList = SortableBindingListFactory.Create();
            PropertyDescriptor propertyDescriptor = PropertyDescriptorHelper.Get(bindingList[0], "Id");
            bindingList.ApplySort(propertyDescriptor, ListSortDirection.Ascending);
            bindingList.RemoveSort();

            Assert.IsFalse(bindingList.IsSorted);
        }

        [TestMethod]
        public void ShouldSetSortPropertyToNull()
        {
            IBindingList bindingList = SortableBindingListFactory.Create();
            PropertyDescriptor propertyDescriptor = PropertyDescriptorHelper.Get(bindingList[0], "Id");
            bindingList.ApplySort(propertyDescriptor, ListSortDirection.Ascending);
            bindingList.RemoveSort();

            Assert.IsNull(bindingList.SortProperty);
        }
    }
}